package edu.hawaii.webspider;

import static org.junit.Assert.*;

import java.io.IOException;
import java.net.MalformedURLException;
import java.util.EmptyStackException;

import org.junit.Test;
import org.xml.sax.SAXException;

/**
 * Test case for the WebSpiderExample class, which checks to see that we can pass different command
 * arguments, and return the expected results.
 * 
 * @author Ivan Wu
 */

public class TestWebSpider {

  /**
   * Test normal stack push.
   * 
   * @exception EmptyStackException If errors during stack processing.
   * @throws SAXException throws saxexception.
   * @throws IOException Throws IOException.
   * @throws MalformedURLException Throws MalformedURLException.
   */
  @Test
  public void testMain() throws EmptyStackException, MalformedURLException, IOException,
      SAXException {
    String runType1 = "-totallinks";
    String runType2 = "-mostpopular";
    String urlString = "http://www.hackystat.org";
    String getMainReturn = "testMain";
    String maximumPages = "5";
    String logging = "-logging";
    String[] args0 = { runType1, urlString, maximumPages, logging, getMainReturn};
    String[] args1 = { runType1, urlString, maximumPages, logging };
    String[] args2 = { runType2, urlString};
    String[] args3 = { runType2, urlString, maximumPages };
    String[] args4 = {};

    assertEquals("Testing testMainMethod.", "141", WebSpiderExample.testMainMethod(args0));
    WebSpiderExample.main(args1);
    WebSpiderExample.main(args2);
    WebSpiderExample.main(args3);
    WebSpiderExample.main(args4);
  }

}
